<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>过滤器</title>
    <script type="text/javascript" src="./../vue.js/vue.js"></script>
    <script type="text/javascript" src="./../vue.js/day.js"></script>
  </head>

  <body>
    <div id="root">
      <h2>{{msg | mySlice}}</h2>
    </div>

    <script type="text/javascript">
      Vue.config.productionTip = false;

      //全局过滤器
      Vue.filter("mySlice", function (value) {
        return value.slice(0, 4);
      });

      new Vue({
        el: "#root",
        data: {
          msg: "hello,atguigu!",
        },
      });
    </script>
  </body>
</html>
